package com.julis.activity.setting;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.Constant;
import com.baseutils.SpfUtils;
import com.julis.R;
import com.suke.widget.SwitchButton;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 菜单设置
 */
public class Setting_menu_Activity extends Activity {


    @BindView(R.id.img_back)
    RelativeLayout imgBack;
    @BindView(R.id.tv_inputvin)
    TextView tvInputvin;
    @BindView(R.id.button_checkvin)
    SwitchButton buttonCheckvin;
    @BindView(R.id.tv_inpuobu)
    TextView tvInpuobu;
    @BindView(R.id.button_inpueobu)
    SwitchButton buttonInpueobu;
    @BindView(R.id.button_shebeigongneng)
    SwitchButton button_shebeigongneng;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settingmenu);
        ButterKnife.bind(this);
        boolean Menu_Liushui = (boolean) SpfUtils.get(this, Constant.Menu_Liushui, true);
        boolean Menu_Recond = (boolean) SpfUtils.get(this, Constant.Menu_Recond, true);
        boolean Menu_SheBei = (boolean) SpfUtils.get(this, Constant.Menu_SheBei, false);

        buttonCheckvin.toggle();     //switch state
        buttonInpueobu.toggle();
        button_shebeigongneng.toggle();

        if (Menu_Liushui) {
            buttonCheckvin.setChecked(true);
        } else {
            buttonCheckvin.setChecked(false);
        }
        if (Menu_Recond) {
            buttonInpueobu.setChecked(true);
        } else {
            buttonInpueobu.setChecked(false);
        }
        if (Menu_SheBei) {
            button_shebeigongneng.setChecked(true);
        } else {
            button_shebeigongneng.setChecked(false);
        }

        buttonCheckvin.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_Liushui, true);
                } else {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_Liushui, false);
                }

            }
        });
        buttonInpueobu.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_Recond, true);
                } else {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_Recond, false);
                }

            }
        });
        button_shebeigongneng.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton view, boolean isChecked) {
                if (isChecked) {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_SheBei, true);
                } else {
                    SpfUtils.put(Setting_menu_Activity.this, Constant.Menu_SheBei, false);
                }

            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }


    @OnClick({R.id.img_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;

        }
    }
}



